﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_DanhMuc.AccessDatabase
{
    
    class DanhMucGiaTP
    {
        AccessData ac = new AccessData(1);
        public int them(int dongia,int banle,string barcode,DateTime ngaylap)
        {
            SqlParameter[] arrpara = new SqlParameter[4];
            arrpara[0] = new SqlParameter("DonGia", SqlDbType.Int);
            arrpara[1] = new SqlParameter("GiaBanLe", SqlDbType.Int);
            arrpara[2] = new SqlParameter("Barcode", SqlDbType.Char);
            arrpara[3] = new SqlParameter("NgayLap",SqlDbType.Date);

            arrpara[0].Value = dongia;
            arrpara[1].Value = banle;
            arrpara[2].Value = barcode;
            arrpara[3].Value = ngaylap;

            DataTable dt = ac.ftblDocDuLieuSP("sp_luugiatp", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(int magiatp)
        {
            var arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("MaGTP", SqlDbType.Int);
            DataTable dt = ac.ftblDocDuLieuSP("sp_xoagiatp", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int sua(int matp,int dongia, int banle, string barcode, DateTime ngaylap)
        {
            SqlParameter[] arrpara = new SqlParameter[5];
            arrpara[0] = new SqlParameter("MaTP", SqlDbType.Int);
            arrpara[1] = new SqlParameter("DonGia", SqlDbType.Int);
            arrpara[2] = new SqlParameter("GiaBanLe", SqlDbType.Int);
            arrpara[3] = new SqlParameter("Barcode", SqlDbType.Char);
            arrpara[4] = new SqlParameter("NgayLap", SqlDbType.Date);

            arrpara[0].Value = matp;
            arrpara[1].Value = dongia;
            arrpara[2].Value = banle;
            arrpara[3].Value = barcode;
            arrpara[4].Value = ngaylap;

            DataTable dt = ac.ftblDocDuLieuSP("sp_suagiatp", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loadluoi()
        {
            return ac.ftblDocDuLieuSP("sp_loadgiatp", null);
        }
    }
}
